package com.rich.house.controller;


import com.rich.common.annotation.IngoreResponseAdvice;
import com.rich.common.dto.house.Result;
import com.rich.house.service.AuditService;
import com.rich.house.vo.AuditVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: guofeng
 * @Date: 2021/08/16/21:39
 * @Description:
 */

@RestController
@RequestMapping("/audit")
public class HouseAuditController {

    @Autowired
    private AuditService auditService;

    /**
     * 返回全部列表
     *
     * @return
     */
    @PostMapping("/findAll")
    @IngoreResponseAdvice
    public List<AuditVo> findAll(@RequestBody AuditVo auditVo) {
        return auditService.findAll(auditVo);
    }

    /**
     * 修改
     *
     * @param auditVo
     * @return
     */
    @RequestMapping("/update")
    public Result update(@RequestBody AuditVo auditVo) {
        try {
            auditService.update(auditVo);
            return new Result("修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result("修改失败");
        }
    }

    /**
     * 获取实体
     *
     * @param auditVo
     * @return
     */
    @RequestMapping("/findOne")
    public AuditVo findOne(@RequestBody AuditVo auditVo) {
        return auditService.findOne(auditVo);
    }


    /**
     * 测试 获取删除的Token
     * @return
     */
    @RequestMapping("createDeleteToken")
    public Result createDeleteToken(){
        return auditService.createDeleteToken();
    }


    /**
     * 删除
     *
     * @param auditVo
     * @return
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody AuditVo auditVo,@RequestHeader("deleteToken")String deleteToken) {
        return auditService.delete(auditVo,deleteToken);
    }

    /**
     * 模糊查询
     * @param
     * @return
     */
//    @RequestMapping("/search")
//    public List<TbInformation> search(@RequestBody TbInformation information) {
//        return auditService.secrch(information);
//    }
}